import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { GCheckBox } from "../../../../com/mui/controls/GCheckBox";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
type int = number;
//class MoneyListRenderer
    
    export  class MoneyListRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this._imgArr = [10, 50, 100, 500, 1000];
            this._spBox = [];
            this.initItem();
            return;
        }

        /* internal  */initItem(): void
        {
            this._gold = new Object /* flash.display.Bitmap */();
            this._gold.y = 5;
            addChild(this._gold);
            this._money = new Object /* flash.display.Bitmap */();
            this._money.x = 13;
            addChild(this._money);
            return;
        }

        protected onSelect(arg1: Object /* flash.events.Event */): void
        {
            var loc1=0;
            while (loc1 < this._spBox.length) 
            {
                if (typeof this._spBox[loc1] === "gcheckbox") 
                {
                    if (this._spBox[loc1].name == arg1.currentTarget.name) 
                    {
                        (arg1.currentTarget as GCheckBox).selected = true;
                        Dispatcher.dispatchEvent(new DataEvent(EventName.OnSelectMoney, (arg1.currentTarget as GCheckBox).name));
                    }
                    else 
                    {
                        (this._spBox[loc1] as GCheckBox).selected = false;
                    }
                }
                ++loc1;
            }
            return;
        }

        /* internal  */onResLoaded(): void
        {
            this._money.bitmapData = GlobalClass.getBitmapData(ImagesConst["ZodiacMoneyIcon_" + this._imgArr[this._index]]);
            this._gold.bitmapData = GlobalClass.getBitmapData(ImagesConst.Yuanbao_small);
            this._gold.x = 13 + this._money.width;
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._index = data.index;
            LoaderHelp.addResCallBack(ResFileConst.Zodiac, this.onResLoaded);
            return;
        }

        /* internal */ /* var */_gold: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_money: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_index: int;

        /* internal */ /* var */_imgArr: Array<any>;

        /* internal */ /* var */_spBox: Array<any>;
    }
